import 'package:dulu/config/global.dart';
import 'package:dulu/iconfont.dart';
import 'package:flutter/material.dart';

class MomtPage extends StatefulWidget {
  MomtPage({
    Key key,
    this.year,
    this.month,
    this.day,
    this.content,
    this.timestamp,
  }) : super(key: key);
  final int year;
  final int month;
  final int day;
  final String content;
  final int timestamp;
  @override
  _MomtPageState createState() => _MomtPageState();
}

class _MomtPageState extends State<MomtPage> {
  @override
  void initState() {
    super.initState();
  }

  String getWeekString() {
    DateTime t = DateTime.parse(
        '${widget.year}-${widget.month > 9 ? widget.month : "0" + widget.month.toString()}-${widget.day > 9 ? widget.day : "0" + widget.day.toString()}');
    List<String> weeksString = ['一', '二', '三', '四', '五', '六', '日'];
    return weeksString[t.weekday - 1];
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
              padding: EdgeInsets.fromLTRB(15, Global.padding.top, 13, 20),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  InkWell(
                    onTap: () {
                      Navigator.of(context).pop();
                    },
                    child: Container(
                      width: 40,
                      child: Icon(IconFont.close),
                    ),
                  ),
                ],
              ),
            ),
            Padding(
              padding: EdgeInsets.fromLTRB(20, 10, 20, 10),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Text(
                        widget.day.toString(),
                        style: TextStyle(
                          fontSize: 50,
                          fontWeight: FontWeight.w600,
                          color: Global.fontColor,
                          fontFamily: 'Kuaile',
                        ),
                      ),
                      SizedBox(width: 10),
                      Column(
                        mainAxisAlignment: MainAxisAlignment.start,
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            '星期${getWeekString()}',
                            style: TextStyle(
                              fontSize: 20,
                              fontWeight: FontWeight.w600,
                              color: Global.fontColor,
                              fontFamily: 'Kuaile',
                            ),
                          ),
                          SizedBox(height: 3),
                          Text(
                            '${widget.year}年${widget.month}月',
                            style: TextStyle(
                              fontSize: 15,
                              fontWeight: FontWeight.w500,
                              color: Global.fontColor,
                              fontFamily: 'Kuaile',
                            ),
                          ),
                        ],
                      )
                    ],
                  ),
                  Text(
                    DateTime(widget.timestamp).hour.toString() +
                        ':' +
                        DateTime(widget.timestamp).minute.toString(),
                    style: TextStyle(
                      fontSize: 20,
                      fontWeight: FontWeight.w500,
                      color: Global.fontColor,
                      fontFamily: 'Kuaile',
                    ),
                  ),
                ],
              ),
            ),
            Padding(
              padding: EdgeInsets.all(20),
              child: Text(
                widget.content,
                maxLines: 15,
                style: TextStyle(
                  color: Global.fontColor,
                  fontFamily: 'Kuaile',
                  fontSize: 20,
                  height: 1.7,
                  letterSpacing: 2,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
